using System;
using System.Collections.Generic;
using System.Text;
using Ghasam.Business.DAO;
using Ghasam.Business.Domain.Entity;
using Spring.Transaction.Interceptor;

namespace Ghasam.Business.Services.Impl
{
    public class InvoiceService : IInvoiceService
    {
        private IInvoiceDao invoiceDao;

        public IInvoiceDao InvoiceDao
        {
            get { return invoiceDao; }
            set { invoiceDao = value; }
        }

        #region IInvoiceService Members

        public int CountInvoices(Invoice exampleInvoice)
        {
            return invoiceDao.CountInvoicesByExample(exampleInvoice);
        }

        public IList<Invoice> FindInvoices(Invoice exampleInvoice, int pageSize, int pageNumber, DateTime lastUpdateStartDate, DateTime lastUpdateEndDate)
        {
            return invoiceDao.GetInvoicesByExample(exampleInvoice, pageSize, pageNumber, lastUpdateStartDate, lastUpdateEndDate);
        }

        public Invoice FindInvoice(int id)
        {
            return invoiceDao.FindById(id);
        }

        [Transaction(ReadOnly = false)]
        public void Persist(Invoice invoice)
        {
            invoiceDao.SaveOrUpdate(invoice);
        }

        #endregion
    }
}
